/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JCorrelationTableView.java
 *
 * Created on 2010-5-29, 8:15:07
 */

package cn.ekuma.epos.analysis.businesspartner;

import cn.ekuma.epos.analysis.businesspartner.AnalysisModelManager.OrderInfoTreeTableNode;
import cn.ekuma.util.SwingUtil;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.treetable.TreeTableNode;

/**
 *
 * @author Administrator
 */
public class JCorrelationTableView extends javax.swing.JPanel {

    AnalysisModelManager manager;
    /** Creates new form JCorrelationTableView */
    public JCorrelationTableView(final AnalysisModelManager manager) {
        initComponents();
        this.manager=manager;   
        jXTreeTable2.setTreeTableModel(manager.getTreeTableModel());
        jXTreeTable2.addTreeSelectionListener(new TreeSelectionListener(){
            public void valueChanged(TreeSelectionEvent e) {
                TreeTableNode selectNode=(TreeTableNode) e.getPath().getLastPathComponent();
                if(selectNode instanceof OrderInfoTreeTableNode){
                    manager.fireOrderChanged(JCorrelationTableView.this,((OrderInfoTreeTableNode)selectNode).getOrderInfo().getOrderId());
                }
            }
        });
        jXTreeTable2.setAutoResizeMode(JXTreeTable.AUTO_RESIZE_OFF);
        jXTreeTable2.setColumnControlVisible(true);
    }

    public void expandALL(){
         jXTreeTable2.expandAll();
         SwingUtil.PreferredJXTreeTableColumn(jXTreeTable2);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jXTreeTable2 = new org.jdesktop.swingx.JXTreeTable();

        setLayout(new java.awt.BorderLayout());

        jScrollPane2.setViewportView(jXTreeTable2);

        add(jScrollPane2, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane2;
    private org.jdesktop.swingx.JXTreeTable jXTreeTable2;
    // End of variables declaration//GEN-END:variables

}
